package org.dragonnova.meetingapp.utils;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import org.dragonnova.meetingapp.R;

/**
 * @Class: UIHelper 
 * @Desp:
 * @Author  songxy 
 * @Date: 2016/1/19  15:24 
 * @version 1.0.0 
 */
public class UIHelper {


    public static AlertDialog getSimpleDialog(Context context, String content) {
        return new AlertDialog.Builder(context).
            setMessage(content).create();
    }

    /**
     * 返回圆角的dialog
     */
    public static Dialog getCircularCornerDialog(Context context, int resId, String remind, String posString, String negString){
        Dialog dialog = new Dialog(context, R.style.dialog);
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.dialog_alert, null);

        Button negButton = (Button) view.findViewById(R.id.dialog_btn_neg);
        Button posButton = (Button) view.findViewById(R.id.dialog_btn_pos);
        TextView remindText = (TextView)view.findViewById(R.id.dialog_remind);
        ImageView remindImg = (ImageView)view.findViewById(R.id.dialog_iv);

        negButton.setText(negString);
        posButton.setText(posString);
        remindText.setText(remind);
        remindImg.setImageResource(resId);

        dialog.setContentView(view);

        return dialog;
    }

    /**
     * 返回一个默认内容的dialog
     */
    public static Dialog getCircularCornerDialog(Context context){
        Dialog dialog = new Dialog(context, R.style.dialog);
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.dialog_alert, null);
        dialog.setContentView(view);
        return dialog;
    }

    /**
     * 设置内容
     */
    public static Dialog setCircularCornerDialogContent(Dialog dialog, int resId, String remind, String posString, String negString){
        Button negButton = (Button) dialog.findViewById(R.id.dialog_btn_neg);
        Button posButton = (Button) dialog.findViewById(R.id.dialog_btn_pos);
        TextView remindText = (TextView)dialog.findViewById(R.id.dialog_remind);
        ImageView remindImg = (ImageView)dialog.findViewById(R.id.dialog_iv);

        negButton.setText(negString);
        posButton.setText(posString);
        remindText.setText(remind);
        remindImg.setImageResource(resId);

        return dialog;
    }

    /**
     * 设置内容
     */
    public static Dialog setCircularCornerDialogContent(Dialog dialog, String remind, String posString, String negString){
        Button negButton = (Button) dialog.findViewById(R.id.dialog_btn_neg);
        Button posButton = (Button) dialog.findViewById(R.id.dialog_btn_pos);
        TextView remindText = (TextView)dialog.findViewById(R.id.dialog_remind);

        negButton.setText(negString);
        posButton.setText(posString);
        remindText.setText(remind);

        return dialog;
    }
}
